package com.jingdun.sport.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingdun.sport.bean.model.Prizes;
import com.jingdun.sport.dao.PrizesMapper;
import com.jingdun.sport.service.PrizesService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
@Slf4j
@AllArgsConstructor
public class PrizesServiceImpl extends ServiceImpl<PrizesMapper, Prizes> implements PrizesService {
    
    private PrizesMapper prizesMapper;
    
    public void addPrize(Prizes prize){
        prizesMapper.addPrize(prize);
    }
    
    public Prizes getPrizeDetail(@Param("params") Map<String, Object> m){
        return prizesMapper.getPrizeDetail(m);
    }
    
    public void updatePrize(Prizes prize){
        prizesMapper.updatePrize(prize);
    }
    
    public Page<Map<String, Object>> getPaginationPrizes(@Param("params") Map<String, Object> m){
        //新建分页
        Page<Map<String,Object>> page = new Page<Map<String,Object>>((long)m.get("current"), (long)m.get("size"));
        //返回结果
        page.setRecords(this.baseMapper.getPaginationPrizes(page, m));
        return page;
    }
}
